import { expect, test } from 'vitest'

import { typedData } from '../../../../test/src/constants.js'
import { wrapTypedDataSignature } from './wrapTypedDataSignature.js'

test('default', () => {
  const signature = {
    r: '0x17f7e62a3921a11100b1f9631ed17c176767719fcc6e6178bf05e44fe0def852',
    s: '0x74e45a4f27940e9bc53f55d8c6934524d461f031059ba41bc0991e52093e53a7',
    v: 28n,
    yParity: 1,
  } as const

  const wrapped = wrapTypedDataSignature({
    ...typedData.complex,
    primaryType: 'Mail',
    signature,
  })

  expect(wrapped).toMatchInlineSnapshot(
    `"0x17f7e62a3921a11100b1f9631ed17c176767719fcc6e6178bf05e44fe0def85274e45a4f27940e9bc53f55d8c6934524d461f031059ba41bc0991e52093e53a71c1788ede5301fb0c4b95dda42eabe811ba83dc3cde96087b00c9b72a4d26a379ac2972c4c4323c6d7ee73e319350f290c6549b6eb516b5e5354128413342332154d61696c2875696e743235362074696d657374616d702c506572736f6e2066726f6d2c506572736f6e20746f2c737472696e6720636f6e74656e74732c62797465732068617368294e616d6528737472696e672066697273742c737472696e67206c61737429506572736f6e284e616d65206e616d652c616464726573732077616c6c65742c737472696e675b335d206661766f72697465436f6c6f72732c75696e7432353620666f6f2c75696e7438206167652c626f6f6c206973436f6f6c2900c1"`,
  )
})
